<template>
<div>
    <el-upload
    class="img-upload"
    :class="{diasbled:isdisabled}"
    ref="upload"
    action="url+'/upload/picture"
    list-type="picture-card"
    accept="image/*"
    :on-preview="handlePreview"
    :on-remove="handleRemove"
    :before-remove="beforeRemove"
    :on-success="handleSuccess"
    :on-error="handleError"
    multiple
    :limit="limit"
    :on-exceed="handleExceed"
    :file-list="fileList"
  >
    <el-button size="small" type="primary">点击上传</el-button>
    <div slot="tip" class="el-upload__tip">
      只能上传jpg/png文件，且不超过500kb
    </div>
  </el-upload>
  <el-dialog :visible.sync="dialogFormVisible">
    <img  width="100%" :src="dialogImageUrl" alt />
  </el-dialog>
</div>
  
</template>
<script>
import{url} from '../../../utils/request'
import{removeFiles} from '../../../api/upload'
export default {
  name: 'ImgUpload',
  data() {
    return {
      fileList: [],
      url:url,
      isdisabled:false,
      dialogImageUrl:''
    }
  },
  methods: {
    handleRemove(file, fileList) {},
    handlePreview(file) {},
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`,
      )
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    handleSuccess(response) {
      this.url = response
      this.$emit('onUpload')
      this.$message.warning('上传成功')
    },
    clear() {
      this.$refs.upload.clearFiles()
    },
  },
}
</script>
